import request from "../../utils/request";

const BASE_URL = "maimao_goods/goods/goods";
export default {

    /**
     * 发布宝贝
     */
    publish(goods) {
        return request({
            url: `${BASE_URL}/publish`,
            method: 'post',
            data: goods
        })
    },
    /**
     * 修改宝贝信息
     * @param goods
     * @returns {AxiosPromise}
     */
    update(goods) {
        return request({
            url: `${BASE_URL}/updateBaby`,
            method: 'post',
            data: goods
        })
    },
    /**
     * 商品详情
     * @param goodsId
     */
    detailInfo(goodsId) {
        return request({
            url: `${BASE_URL}/detail/${goodsId}`,
            method: 'get'
        })
    },
    testkafk(id) {
        return request({
            url: `${BASE_URL}/kafka/${id}`,
            method: 'post'
        })
    },

    shopGoods(shopId, key, page, size) {
        return request({
            url: `${BASE_URL}/goods-shop-simple?shopId=${shopId}&key=${key}&page=${page}&size=${size}`,
            method: 'get'
        })
    },

    /**
     * 卖家中心查询商品
     */
    shopGoodsList(searchData, page, size) {
        return request({
            url: `${BASE_URL}/shop-goods-list?page=${page}&size=${size}`,
            method: 'post',
            data: searchData
        })
    },

    /**
     * 上下架
     * @param goodsId
     * @param status 1 上架  0 下架
     */
    updateOnSellStatus(goodsId, status) {
        return request({
            url: `${BASE_URL}/update-onSell`,
            method: 'post',
            data: {
                id: goodsId,
                status: status
            }
        })
    },

    /**
     * 编辑商品 查询商品信息进行回显
     * @param goodsId
     * @returns {AxiosPromise}
     */
    goodsEditInfo(goodsId){
        return request({
            url:`${BASE_URL}/goodsinfo-byid?goodsId=${goodsId}`,
            method:'get'
        })
    },

    /**
     * 添加商品点击
     * @param goodsId
     * @returns {AxiosPromise}
     */
    addClickCount(goodsId){
        return request({
            url:`${BASE_URL}/click-goods?goodsId=${goodsId}`,
            method:'get'
        })
    }


}

